package com.atguigu.lease.web.admin.controller.apartment;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.entity.PaymentType;
import com.atguigu.lease.web.admin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: PaymentTypeController
 * Package: com.atguigu.lease.web.admin.controller.apartment
 * Description:
 *
 * @Author ygf
 * @Create 2024/9/3 9:26
 * @Version 1.0
 */
@Tag(name = "支付管理接口")
@RestController
@RequestMapping("/admin/payment")
public class PaymentTypeController {

    @Autowired
    private PaymentTypeService paymentTypeService;

    @Operation(summary = "查询所有支付方式")
    @GetMapping("/list")
    public Result selectAllPaymentTypeList(){
        //调用service层
        List<PaymentType> paymentTypeList = paymentTypeService.list();
        return Result.ok(paymentTypeList);
    }
    @Operation(summary = "添加或更新支付方式")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody PaymentType paymentType){
        //调用service层
        paymentTypeService.saveOrUpdate(paymentType);
        return Result.ok();
    }

    @Operation(summary = "根据id删除支付方式")
    @DeleteMapping("/deleteById")
    public Result deleteById(@RequestParam(value = "id",required = true) Long id){
        //调用service层
        paymentTypeService.removeById(id);
        return Result.ok();
    }
}
